package com.gitee.exporttool.util;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class LocalDateUtils {

    public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";

    public static final LocalDate getNowDate() {
        return LocalDate.now();
    }

    public static final String getStringNowDate() {
        return DateTimeFormatter.BASIC_ISO_DATE.format(LocalDate.now());
    }

    public static final String getStringNowDate(String format) {
        return DateTimeFormatter.ofPattern(format).format(LocalDate.now());
    }

    public static final String dateTimeNow() {
        return dateTimeNow(YYYYMMDDHHMMSS);
    }

    public static final String dateTimeNow(final String format) {
        return parseLocalDateTimeToStr(format, LocalDateTime.now());
    }

    public static final String parseLocalDateTimeToStr(final String format, LocalDateTime localDateTime) {
        return DateTimeFormatter.ofPattern(format).format(localDateTime);
    }
}
